#!/usr/bin/env node
const inquirer = require("inquirer")
const fs = require("fs")
const path = require("path")
const ejs = require("ejs")

inquirer.prompt([{
    type:'input',
    name:'name',
    message:'Project name?'
}])
.then(anwsers => {
    const tmlpDir = path.join(__dirname, 'templates')

    const destDir = process.cwd()

    fs.readdir(tmlpDir, (err,files)=>{
        if(err) throw err
        files.forEach(file=>{
            ejs.renderFile(path.join(tmlpDir, file), anwsers, (err,result) =>{
                if(err) throw err

                fs.writeFileSync(path.join(destDir, file), result)
            })
        })
    })

})